#include "uilineedit.h"

#include <QKeyEvent>

UiLineEdit::UiLineEdit(QWidget *parent)
{

}

QString UiLineEdit::value() const
{
    return m_value;
}

void UiLineEdit::setValue(const QString &value)
{
    if(value != m_value)
        m_value = value;
}

void UiLineEdit::focusOutEvent(QFocusEvent *event)
{
    if(this->text() != value())
        emit sigEditFinished();
    QLineEdit::focusOutEvent(event);
}

void UiLineEdit::keyPressEvent(QKeyEvent *event)
{
    if(event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
    {
        if(this->text() != value())
            emit sigEditFinished();
    }
    QLineEdit::keyPressEvent(event);
}
